package connection {
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.geom.Point;

import geditor.common.DrawPoint;
import geditor.events.ChangeEvent;

/**
 * ConnectionPoint based on DrawPoint
 */
public class SimpleConnectionPoint extends EventDispatcher implements ConnectionPoint {
    private var _p:DrawPoint;
    private var _parent:Connectable;

    public function SimpleConnectionPoint(p:DrawPoint, parent:Connectable) {
        _p = p;
        _parent = parent;
        _p.addEventListener("change", _pointChange);
    }

    private function _pointChange(evt:Event):void {
        dispatchEvent(new ChangeEvent());
    }

    override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void {
        super.addEventListener(type, listener, useCapture, priority, useWeakReference);
    }

    public function get point():Point {
        return _p.point;
    }

    public function canConnect(conn:ConnectionComponent, start:Boolean):Boolean {
        return true;
    }

    public function get connectable():Connectable {
        return _parent;
    }
}
}